﻿@{
    ViewBag.Title = "CacheRequest";
    Layout = "~/Views/Shared/_Page.cshtml";
}

<h2>Cache Request</h2>

<ul id="employeeList"></ul>
<button id="getEmployee">Get Employees</button>

<script type="text/javascript">
    var cacheEmp = [];
    var count = 0;
    $(document).ready(function () {
        $('#getEmployee').click(function () {
            count++;
            if (cacheEmp.length == 0) {
                $.ajax({
                    url: '/Employee/EmployeeList',
                    contentType: "application/json; charset=utf-8",
                    type: 'POST',
                    async: false
                }).done(function (data) {
                    cacheEmp = $.parseJSON(data);
                    ZEUS.DEBUG.log(cacheEmp.length);
                });
            }

            ZEUS.DEBUG.log("Load " + count + " Times");

            $('#employeeList').empty();
            $.each(cacheEmp, function (key, value) {
                $('#employeeList').append("<li>#" + key + ": " + value.Name + ", " + value.Age + ", " + value.Title + "</li>");
            });
        });
    });
</script>
